﻿using System;


namespace HAVNet.Intros.AST
{
    public enum ASTTypeKind
    {
        _,                  /* None..               */
        Primitive,          /* int, float, double   */
        Class,              /* Person, Employee     */
        ClassInternal,      /* object, string       */
        Void,               /* void                 */
    }

    public class ASTType : ASTNode
    {
        public ASTTypeKind  typeKind        { get; set; }   /* tipo de tipo... */
        public ASTTypeName  typeName        { get; set; }   /* ej: void   int   Persona    MiGenerico<int> */
        public bool         isNullable      { get; set; }   /* tiene '?'                */
        public bool         isArray         { get; set; }   /* tiene [,,,] o [][] o []  */
        public bool         isPointer       { get; set; }   /* tiene '*'                */
        public int          dimensions      { get; set; }   /* cantidad de dimensiones  */
        public string       textPtrOrArray  { get; set; }   /* ej: "[,,]" "[]" "[][][]" "*" */
        
        public override string ToString ()
        {
            string s = typeName.ToString ();

            if (isNullable)
                s += " ?";

            if (isPointer)
                s += " *";

            if (isArray)
                s += " " + textPtrOrArray.Trim ();

            return s;
        }
    }
}
